﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Artemis;

namespace JAWWS
{
    class AmmoItem : Item
    {
        private int Ammo;
        private bool pickedUp;

        public AmmoItem(MainForm main, float[] pos)
        {
            this.position = pos;
            this.Ammo = 15;
            this.child = null;
            this.sibling = null;
            this.TexId = main.TexIDs[1];
            this.LocalTransMatrix = this.IdMatrix;
            this.type = ItemName.AMMO_PACK;
            pickedUp = false;
        }
        public int getAmmoCount()
        {
            return Ammo;
        }
        public bool getPickedUp()
        {
            return pickedUp;
        }
        public void setPickedUp(bool arg)
        {
            pickedUp = arg;
        }
        public override void apply(Player player)
        {
            //Will only add ammo when the Ammo count is not over 100
            if (player.getCurrentWeapon().getAmmoCount() <= 100)
            {
                if (player.getCurrentWeapon().getAmmoCount() >= 85)
                {
                    //Caps the ammo increase to 100
                    player.getCurrentWeapon().modifyAmmo((100 - player.getCurrentWeapon().getAmmoCount()));
                }
                else
                {
                    player.getCurrentWeapon().modifyAmmo(Ammo);
                }
            }
        }
        public override void draw()
        {
            //Will not draw the object when its picked up.
            if (pickedUp == false)
            {
                GL.glEnable(GLenum.GL_TEXTURE_2D);
                GL.glBindTexture(GLenum.GL_TEXTURE_2D, this.TexId);
                Toolkit.SolidCube(0.5f);
                GL.glDisable(GLenum.GL_TEXTURE_2D);
            }
        }
        public void updateAmmoPack()
        {
            GL.glPushMatrix();
                GL.glLoadIdentity();
                GL.glTranslatef(position[0], position[1], position[2]);
                GL.glGetFloatv(GLenum.GL_MODELVIEW_MATRIX, this.LocalTransMatrix);
            GL.glPopMatrix();
        }
    }
}
